/* 
 * File:   OCRToolkit.h
 * Author: liuyi
 *
 * Created on July 21, 2009, 4:58 PM
 */

#ifndef _OCR_H
#define	_OCR_H

#include "header.h"
#include "FontLib.h"
#include "ml/SampleSpace.h"

#include <vector>

using namespace std;

class KNN;

class OCR {
public:
    // not thread safe
    static void preRecognize();
    
    static void release();

    static void train();

    static ushort recognize(const uchar *greyData, int width, int height);

    /*
     *@param rx region x coordinate on src image
     *@param rx region y coordinate on src image
     *@param rw region width
     *@param rh region height
     */
    static void normalize(uchar* dst, const uchar* src, int sw, int rx, int ry, int rw, int rh);

private:
    static const int s_K = 4;

    static SampleSpace *s_sampleSpace;
    static KNN *s_knn;

    static void trainSubset(vector<string> &pathList);

    OCR() { }
    virtual ~OCR() { }

};

#endif	/* _OCRTOOLKIT_H */

